#ifndef _SM2_H
#define _SM2_H

#include "sm2_ec.h"
#include "sm2_operation.h"
#include "sm3.h"
#include "sm2_5_naf.h"
#include <stdlib.h>
#include <stdint.h>
#include "sm2_safegcd.h"
#include "Crypto_Types.h"
#include "sm2_format.h"

typedef struct {
    sm2_uint256_t private_key;
    SM2_Point public_key;
}SM2_Key;


typedef struct {
	uint8_t r[32];
	uint8_t s[32];
} SM2_Signature;

//FUNC(Std_ReturnType, CRY_CODE)
void sm2_signature_generate(const uint8_t pri_key_bytes[32], const uint8_t Z_A[32], const uint8_t* message, size_t message_size, SM2_Signature *sig);

int sm2_signature_verify(const uint8_t pub[64], const uint8_t Z_A[32], const uint8_t* message, uint32_t message_size, const uint8_t sig[64]);

void sm2_compute_z(uint8_t Z_A[32], const SM2_Point *pub, const uint8_t *id, unsigned short n_bytes);


//void sm2_signature_generate(const uint8_t pri_key_bytes[32], const uint8_t Z_A[32], const uint8_t* message, size_t message_size, SM2_Signature *sig);
//int sm2_signature_verify(const uint8_t pub[64], const uint8_t Z_A[32], const uint8_t* message, uint32_t message_size, const uint8_t sig[64]);
//
//void sm2_compute_z(uint8_t Z_A[32], const SM2_Point *pub, const uint8_t *id, unsigned short n_bytes);



#define SM2_MIN_SIGNATURE_SIZE 8
#define SM2_MAX_SIGNATURE_SIZE 72


#define SM2_DEFAULT_ID		"1234567812345678"
#define SM2_DEFAULT_ID_LENGTH	(sizeof(SM2_DEFAULT_ID) - 1)  // LENGTH for string and SIZE for bytes
#define SM2_DEFAULT_ID_BITS	(SM2_DEFAULT_ID_LENGTH * 8)
#define SM2_MAX_ID_BITS		65535
#define SM2_MAX_ID_LENGTH	(SM2_MAX_ID_BITS/8)


#endif
